package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Square;
import com.skyolder.milkbee.repository.SquareRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Square.
 */
@Service
@Transactional
public class SquareService {

    private final Logger log = LoggerFactory.getLogger(SquareService.class);
    
    @Inject
    private SquareRepository squareRepository;

    /**
     * Save a square.
     *
     * @param square the entity to save
     * @return the persisted entity
     */
    public Square save(Square square) {
        log.debug("Request to save Square : {}", square);
        Square result = squareRepository.save(square);
        return result;
    }

    /**
     *  Get all the squares.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Square> findAll(Pageable pageable) {
        log.debug("Request to get all Squares");
        Page<Square> result = squareRepository.findAll(pageable);
        return result;
    }

    /**
     *  Get one square by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Square findOne(Long id) {
        log.debug("Request to get Square : {}", id);
        Square square = squareRepository.findOne(id);
        return square;
    }

    /**
     *  Delete the  square by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Square : {}", id);
        squareRepository.delete(id);
    }
}
